package com.xqboss.apps.domain.order;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.xqboss.apps.domain.BaseTable;
import com.xqboss.apps.enums.market.MarketTypeEnum;
import com.xqboss.apps.enums.order.OrderStatusEnum;
import com.xqboss.apps.enums.order.OrderTypeEnum;
import com.xqboss.apps.enums.order.RefundStatusEnum;
import com.xqboss.apps.enums.user.PayTypeEnum;
import com.xqboss.common.core.domain.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.data.annotation.Id;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 * 订单主表
 * </p>
 *
 * @author lang.liu
 * @since 2021-11-26
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
//@Document(indexName = "order_main")
@ApiModel(value = "OrderMain对象", description = "订单主表")
public class OrderMain extends BaseTable {

    private static final long serialVersionUID = 1L;

    @Id
    @TableId
    @ApiModelProperty(value = "主键ID")
    private Long id;

    @ApiModelProperty(value = "买家用户ID")
    private Long buyerUserId;

    @ApiModelProperty(value = "买家用户昵称")
    private String buyerNick;

    @ApiModelProperty(value = "卖家用户ID")
    private Long sellerUserId;

    @ApiModelProperty(value = "公会ID")
    private Long guildId;

    @ApiModelProperty(value = "卖家用户昵称")
    private String sellerNick;

    @ApiModelProperty(value = "买家备注")
    private String buyerMemo;

    @ApiModelProperty(value = "卖家备注")
    private String sellerMemo;

    @ApiModelProperty(value = "订单类型")
    private OrderTypeEnum orderType;

    @ApiModelProperty(value = "市场类型")
    private MarketTypeEnum marketType;

    @ApiModelProperty(value = "支付方式")
    private PayTypeEnum payType;

    @ApiModelProperty(value = "商品数量")
    private Integer skuCnt;

    @ApiModelProperty(value = "订单总金额（不扣除优惠和抵扣的金额，包含服务费，包含运费，差价）")
    private BigDecimal totalAmount;

    @ApiModelProperty(value = "应付金额（扣除优惠和抵扣后的金额，包含服务费，包含运费，差价）")
    private BigDecimal paymentAmount;

    @ApiModelProperty(value = "交易手续费")
    private BigDecimal transactionFee;

    @ApiModelProperty(value = "实际付款金额（包含运费，包含服务费）")
    private BigDecimal actualPaymentAmount;

    @ApiModelProperty(value = "订单状态")
    private OrderStatusEnum status;

    @ApiModelProperty(value = "售后状态,0未售后,1待审核,2审核拒绝,3审核通过,4待发货,5待收货,6待退款(已收货),7已退款,8会员撤销")
    private RefundStatusEnum refundStatus;

    @ApiModelProperty(value = "支付账号")
    private String payAccount;

    @ApiModelProperty(value = "支付流水号")
    private String payOrderNo;

    @ApiModelProperty(value = "支付时间")
    @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime payTime;

    @ApiModelProperty(value = "发货时间")
    @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime shippedTime;

    @ApiModelProperty(value = "送达时间")
    @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime arriveTime;

    @ApiModelProperty(value = "收货时间")
    @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime receivedTime;

    @ApiModelProperty(value = "取消时间")
    @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime cancelTime;

    @ApiModelProperty(value = "订单过期时间(未付款自动取消)")
    @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime autoCancelTime;

    @ApiModelProperty(value = "是否需要发票,0不需要,1需要")
    private Boolean isInvoice;

    @ApiModelProperty(value = "是否已经结算")
    private Boolean isSettle;

    @ApiModelProperty(value = "是否是优先购")
    private Boolean isPriority;

    @ApiModelProperty(value = "异常标记")
    private Boolean exception;

    // 子订单信息
    @TableField(exist = false)
    private List<OrderItem> orderItems;

    //用户手机号
    @TableField(exist = false)
    private String userPhonenumber;
}
